package au.com.evoCoach.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;

import au.com.evoCoach.enums.RookieStatus;

@Entity
public class TeamPlayer {
	private int id;
	private Team team;
	private Player player;
	private RookieStatus rookieStatus;
	
	@Id
	@GeneratedValue
	@Column
	public int getId() {
		return id;
	}
	
	public void setId(int id) {
		this.id = id;
	}
	
	private TeamPlayer() {}
	
	public TeamPlayer(Team team, Player player) {
		super();
		this.team = team;
		this.player = player;
	}

	@OneToOne
    @JoinColumn(name="teamId")
	public Team getTeam() {
		return team;
	}
	
	public void setTeam(Team team) {
		this.team = team;
	}
	
	@OneToOne
    @JoinColumn(name="playerId")
	public Player getPlayer() {
		return player;
	}

	public void setPlayer(Player player) {
		this.player = player;
	}
	
	@Enumerated(EnumType.STRING)
	public RookieStatus getRookieStatus() {
		return rookieStatus;
	}

	public void setRookieStatus(RookieStatus rookieStatus) {
		this.rookieStatus = rookieStatus;
	}
	
	@Override
	public boolean equals(Object obj) {
	    TeamPlayer reqObj = (TeamPlayer) obj;
	    return reqObj.getTeam().equals(team) && reqObj.getPlayer().equals(player);
	}
	
}
